﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Folder.cs" company="HelloWorld">
//   BY苏宣
// </copyright>
// <summary>
//   Defines the Folder type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WindowsFormsApp2.Model
{
    using System.Collections.Generic;
    using System.IO;

    // 一级文件夹管理类

    /// <summary>
    /// The folder.
    /// </summary>
    internal class Folder
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        public Folder(string name)
        {
            this.FolderName = name;

            this.Parts = new Dictionary<string, List<string>>
                             {
                                 { "公共", new List<string>() },
                                 { "笔记", new List<string>() },
                                 { "资源", new List<string>() }
                             };
        }

        /// <summary>
        /// Gets or sets the folder name.
        /// </summary>
        public string FolderName { get; set; }

        /// <summary>
        /// Gets or sets the parts.
        /// </summary>
        public Dictionary<string, List<string>> Parts { get; set; }

        // 初始化

        /// <summary>
        /// The initialization.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        public void Init(string path)
        {
            foreach (var key in this.Parts.Keys)
            {
                var files = Directory.GetFiles(path + @"/" + key);
                this.Parts[key].AddRange(files);
            }
        }
    }
}
